package com.cuit.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cuit.pojo.Book;
import com.cuit.service.BookService;
import io.swagger.annotations.Api;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;


@CrossOrigin //开放前端的跨域访问
@Api(tags = "书本管理")
@Controller
@RequestMapping("/book")
public class BookGGController {
    @Resource
    private BookService bookService;

    @GetMapping("/selectAll")
    public String selectAll(ModelMap modelMap, @RequestParam(value = "pn", defaultValue = "1") Integer pn){
        Page<Book> bookPage = new Page<>(pn, 5);
        Page<Book> page = bookService.page(bookPage,null);
        modelMap.addAttribute("page",page);
        return "admin/widgets-bookData";
    }
}
